import { defineStore } from 'pinia'
import { requestRecomment, requestBannerList, requestRecommentPoemsList } from './home.api'

export default defineStore('home', {
    state: () => {
        return {
        }
    },
    getters: {
    },
    actions: {
        getBannerList() {
            return new Promise((resolve, reject) => {
                requestBannerList().then(response => {
                    const res: any = response.data
                    if (res.code === 200) {
                        resolve(res.data)
                    }
                })
            })
        },
        getRecomment(data: Object = {}) {
            return new Promise((resolve, reject) => {
                requestRecomment(data).then(response => {
                    const res: any = response.data
                    if (res.code === 200) {
                        resolve(res.data)
                    }
                })
            })
        },
        // 获取诗单
        getRecommentPoemsList(data: Object) {
            return new Promise((resolve, reject) => {
                requestRecommentPoemsList(data).then(response => {
                    const res: any = response.data
                    if (res.code === 200) {
                        resolve(res.data)
                    }
                })
            })
        },
    }
})
